﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using XLuSharpLibrary.DbAccess;
using BHair.Business.Table;


using System.ComponentModel;

using System.Drawing;


using System.Windows.Forms;

using System.Configuration;
using System.Threading;

namespace BHair.Business.BaseData
{
    /// <summary>会员信息管理。</summary>
    public class Member
    {
        public static string oldcard = "";
        string constr = ConfigurationManager.ConnectionStrings["BHair.Properties.Settings.BHairDBConnectionString"].ConnectionString;
        #region 构造函数...

        /// <summary>会员信息管理。</summary>
        public Member()
        { }

        /// <summary>会员信息管理。</summary>
        /// <param name="mid">会员编号</param>
        public Member(string mid)
        {
            this.UpdateBalance(mid);
            string strSql = "select * from member where mid='" + mid + "'";
            DataRow objRow = StaticValue.SelectTable(strSql).Rows[0];
            this.ID = objRow["mid"].ToString();
            this.Name = objRow["mname"].ToString();
            this.Status = int.Parse(objRow["mstatus"].ToString());
            this.CardID = int.Parse(objRow["mcid"].ToString());
            this.Password = objRow["mpass"].ToString();
            this.Remark = objRow["mremark"].ToString();
            this.Sex = int.Parse(objRow["msex"].ToString());
            this.Month = int.Parse(objRow["mmonth"].ToString());
            this.Day = int.Parse(objRow["mday"].ToString());
            this.Phone = objRow["mphone"].ToString();
            this.Address = objRow["maddress"].ToString();
            this.Other = objRow["mother"].ToString();
            this.JoinDate = DateTime.Parse(objRow["mjoin"].ToString());
            this.IDCard = objRow["midcard"].ToString();
            this.Balance = decimal.Parse(objRow["mbalance"].ToString());
            this.Point = int.Parse(objRow["mpoint"].ToString());
            this.Ifyxq = int.Parse(objRow["ifyxq"].ToString());
            this.Yxq = objRow["yxq"].ToString();
            this.Shengao = objRow["shengao"].ToString();
            this.Tizhong = objRow["tizhong"].ToString();
            this.Xiongwei = objRow["xiongwei"].ToString();
            this.Yaowei = objRow["yaowei"].ToString();
            this.Tunwei = objRow["tunwei"].ToString();
            this.Biwei = objRow["biwei"].ToString();
            this.Tuiwei = objRow["tuiwei"].ToString();
            this.Age =Int32.Parse( objRow["age"].ToString());
            this.积分 = decimal.Parse(objRow["积分"].ToString());
            this.会员级别 =objRow["会员级别"].ToString();
            if (objRow["image"].ToString() != string.Empty)
            {
                this.Image = (byte[])objRow["image"];
            }
            else { }
            
            try
            {
                this.LastTime = DateTime.Parse(objRow["mlastime"].ToString());
            }
            catch
            { }
        }

        #endregion

        #region 属性...

        #region 读写属性...
        private string 会员级别1;
       // private decimal jf;
        private string _ID;
        private decimal 积分1;

        /// <summary>获取或设置会员卡号，会员唯一标识。</summary>
        public string ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        private int age;

        private string _Name;

        /// <summary>获取或设置会员姓名。</summary>
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        private int _Status;

        /// <summary>获取或设置会员状态。（0正常；1停用）</summary>
        public int Status
        {
            get { return _Status; }
            set { _Status = value; }
        }

        private int _CardID;

        /// <summary>获取或设置会员卡类型ID。</summary>
        public int CardID
        {
            get { return _CardID; }
            set { _CardID = value; }
        }

        private string _Password;

        /// <summary>获取或设置会员密码。</summary>
        public string Password
        {
            get { return _Password; }
            set { _Password = value; }
        }

        private string _Remark;

        /// <summary>获取或设置会员备注。</summary>
        public string Remark
        {
            get { return _Remark; }
            set { _Remark = value; }
        }

        private int _Sex;

        /// <summary>获取或设置会员性别。</summary>
        public int Sex
        {
            get { return _Sex; }
            set { _Sex = value; }
        }

        private int _Month;

        /// <summary>获取或设置会员出生日期(月)。</summary>
        public int Month
        {
            get { return _Month; }
            set { _Month = value; }
        }

        private int _Day;

        /// <summary>获取或设置会员出生日期(日)。</summary>
        public int Day
        {
            get { return _Day; }
            set { _Day = value; }
        }

        private string _Phone;

        /// <summary>获取或设置会员联系电话。</summary>
        public string Phone
        {
            get { return _Phone; }
            set { _Phone = value; }
        }

        private string _Address;

        /// <summary>获取或设置会员联系地址。</summary>
        public string Address
        {
            get { return _Address; }
            set { _Address = value; }
        }
        private int ifyxq;
        /// <summary>
        /// 是否限制有效期1为限制0为不限制
        /// </summary>
        public int Ifyxq
        {
            get
            {
                return ifyxq;
            }

            set
            {
                ifyxq = value;
            }
        }
        private string yxq;
        /// <summary>
        /// 有效期
        /// </summary>
        public string Yxq
        {
            get
            {
                return yxq;
            }

            set
            {
                yxq = value;
            }
        }
        private string _Other;

        /// <summary>获取或设置会员其它信息。</summary>
        public string Other
        {
            get { return _Other; }
            set { _Other = value; }
        }

        private DateTime _JoinDate;

        /// <summary>获取或设置会员加入日期。</summary>
        public DateTime JoinDate
        {
            get { return _JoinDate; }
            set { _JoinDate = value; }
        }

        private string _IDCard;

        /// <summary>获取或设置会员身份证号码。</summary>
        public string IDCard
        {
            get { return _IDCard; }
            set { _IDCard = value; }
        }

        private decimal _Balance;

        /// <summary>获取或设置会员当前可用余额。</summary>
        public decimal Balance
        {
            get { return _Balance; }
            set { _Balance = value; }
        }
        private decimal Csje;
        /// <summary>
        /// 会员初始金额
        /// </summary>
        public decimal Csje1
        {
            get
            {
                return Csje;
            }

            set
            {
                Csje = value;
            }
        }



        private int _Point = 0;

        /// <summary>获取或设置会员当前可用积分。</summary>
        public int Point
        {
            get { return _Point; }
            set { _Point = value; }
        }

        private DateTime? _LastTime;

        /// <summary>获取或设置会员最近光顾日期。</summary>
        public DateTime? LastTime
        {
            get { return _LastTime; }
            set { _LastTime = value; }
        }
        private byte[] image;
        public byte[] Image
        {
            get
            {
                return image;
            }

            set
            {
                image = value;
            }
        }
        #endregion

        #region 只读属性...

        private string _SexText;

        /// <summary>获取会员性别(文本值)。</summary>
        public string SexText
        {
            get
            {
                _SexText = "男";
                if (this.Sex == 0)
                {
                    _SexText = "女";
                }
                return _SexText;
            }
        }

        private string _Birthday;

        /// <summary>获取会员出生日期。</summary>
        public string Birthday
        {
            get
            {
                _Birthday = "";
                if (this.Month > 0)
                {
                    _Birthday = this.Month + "月";
                    if (this.Day > 0)
                    {
                        _Birthday += this.Day + "日";
                    }
                }
                return _Birthday;
            }
        }

        private Card _Card = new Card();

        /// <summary>获取会员类型。</summary>
        public Card Card
        {
            get
            {
                if (this.CardID > 0)
                {
                    _Card = new Card(this.CardID);
                }
                return _Card;
            }
        }

        private string _StatusText;

        /// <summary>获取会员当前状态(文本值)。</summary>
        public string StatusText
        {
            get
            {
                if (this.Status == 0)
                {
                    _StatusText = "正常";
                }
                else
                {
                    _StatusText = "停用";
                }
                return _StatusText;
            }
        }

        private string _LastDeposit;
        /// <summary>
        /// 设置体重
        /// </summary>
        private string tizhong;
        public string Tizhong
        {
            get
            {
                return tizhong;
            }

            set
            {
                tizhong = value;
            }
        }
        /// <summary>
        /// 身高
        /// </summary>
        private string shengao;
        public string Shengao
        {
            get
            {
                return shengao;
            }

            set
            {
                shengao = value;
            }
        }
        
        private string xiongwei;
        /// <summary>
        /// 胸围
        /// </summary>
        public string Xiongwei
        {
            get
            {
                return xiongwei;
            }

            set
            {
                xiongwei = value;
            }
        }
        private string yaowei;
        /// <summary>
        /// 腰围
        /// </summary>
        public string Yaowei
        {
            get
            {
                return yaowei;
            }

            set
            {
                yaowei = value;
            }
        }
        private string tunwei;
        /// <summary>
        /// 臀围
        /// </summary>
        public string Tunwei
        {
            get
            {
                return tunwei;
            }

            set
            {
                tunwei = value;
            }
        }
        private string tuiwei;
        private string biwei;
        /// <summary>获取最近一次充值。</summary>
        public string LastDeposit
        {
            get
            {
                if (this.ID != null || this.ID != "")
                {
                    string strSql = "select top 1 * from deposit where dmid='" + this.ID + "' and dmode=0 order by ddate desc";
                    DataTable objDataTable = StaticValue.SelectTable(strSql);
                    if (objDataTable.Rows.Count > 0)
                    {
                        _LastDeposit = DateTime.Parse(objDataTable.Rows[0]["ddate"].ToString()).ToShortDateString() + " ￥" + decimal.Parse(objDataTable.Rows[0]["dmoney"].ToString()).ToString("f2");
                    }
                }
                return _LastDeposit;
            }
        }

        public string Biwei
        {
            get
            {
                return biwei;
            }

            set
            {
                biwei = value;
            }
        }

        public string Tuiwei
        {
            get
            {
                return tuiwei;
            }

            set
            {
                tuiwei = value;
            }
        }

        public int Age
        {
            get
            {
                return age;
            }

            set
            {
                age = value;
            }
        }

       

        public string 会员级别
        {
            get
            {
                return 会员级别1;
            }

            set
            {
                会员级别1 = value;
            }
        }

        public decimal 积分
        {
            get
            {
                return 积分1;
            }

            set
            {
                积分1 = value;
            }
        }
























        #endregion

        #endregion

        #region 自定义函数...

        /// <summary>检查是否存在相同会员卡号，返回空字符串时为不存在。</summary>
        /// <param name="mid">会员卡号</param>
        /// <returns></returns>
        public string ExistsMemberCard(string mid)
        {
            string strSql = "select * from member where mid=@mid";
            SqlParameter[] cmdParameter = { new SqlParameter("@mid", mid) };
            DataTable objDataTable = new DataTable();
            new SQLHelper().ExecuteSql(strSql, cmdParameter, out objDataTable);
            if (objDataTable.Rows.Count > 0)
            {
                return objDataTable.Rows[0]["mid"].ToString();
            }
            return "";
        }

        /// <summary>查询会员信息。</summary>
        /// <param name="membertext">会员卡号或姓名</param>
        /// <param name="enabled">显示不可用会员</param>
        /// <returns></returns>
        public List<Member> SelectList(string membertext, bool enabled )
        {
            //优先显示生日会员
            //string strSql1 = "select *,(select sum(dmoney) from deposit where dmid=member.mid) as sumdep,(select sum(pmoney) from pays where pmid=member.mid and ptype=1) as sumpay from member where (datepart(month,getdate())<=mmonth and datepart(day,getdate())<=mday)";
            string strSql1 = "select * from member where (datepart(month,getdate())<=mmonth and datepart(day,getdate())<=mday)";
            string strSql2 = "select * from member where 1=1";
            if (membertext != "")
            {
                strSql1 += " and (mid like '%" + membertext + "%' or mname like '%" + membertext + "%' or mphone like '%"+membertext+"%')";
                strSql2 += " and (mid like '%" + membertext + "%' or mname like '%" + membertext + "%' or mphone like '%"+membertext+"%')";
            }
            if (enabled)
            {
                strSql1 += " and mstatus=1";
                strSql2 += " and mstatus=1";
            }
            else
            {
                strSql1 += " and mstatus=0";
                strSql2 += " and mstatus=0";
            }
            strSql1 += " order by mmonth,mday";
            strSql2 += " order by mmonth,mday";
            DataTable objTable1 = StaticValue.SelectTable(strSql1);
            DataTable objTable2 = StaticValue.SelectTable(strSql2);
            //合并表
            objTable1.Merge(objTable2);
            DataTable objTable = StaticValue.GetDistinctTable(objTable1, "mid");
            List<Member> lstMember = new List<Member>();
            foreach (DataRow objRow in objTable.Rows)
            {
                lstMember.Add(this.GetMemberForRow(objRow));
            }
            return lstMember;
        }

        private Member GetMemberForRow(DataRow objRow)
        {
            Member objMember = new Member();
            objMember.ID = objRow["mid"].ToString();
            objMember.Name = objRow["mname"].ToString();
            objMember.Status = int.Parse(objRow["mstatus"].ToString());
            objMember.CardID = int.Parse(objRow["mcid"].ToString());
            objMember.Password = objRow["mpass"].ToString();
            objMember.Remark = objRow["mremark"].ToString();
            objMember.Sex = int.Parse(objRow["msex"].ToString());
            objMember.Month = int.Parse(objRow["mmonth"].ToString());
            objMember.Day = int.Parse(objRow["mday"].ToString());
            objMember.Phone = objRow["mphone"].ToString();
            objMember.Address = objRow["maddress"].ToString();
            objMember.Other = objRow["mother"].ToString();
            objMember.JoinDate = DateTime.Parse(objRow["mjoin"].ToString());
            objMember.IDCard = objRow["midcard"].ToString();
            objMember.Balance = decimal.Parse(objRow["mbalance"].ToString());
            objMember.积分 = decimal.Parse(objRow["积分"].ToString());
           // objMember.Point = int.Parse(objRow["mpoint"].ToString());
            try
            {
                objMember.LastTime = DateTime.Parse(objRow["mlastime"].ToString());
            }
            catch
            { }
            return objMember;
        }

        /// <summary>获取会员总数量</summary>
        /// <param name="mode">查询方式(0可用，1不可用，2全部)</param>
        /// <param name="cid">会员卡类型(0所有)</param>
        /// <returns></returns>
        public static int GetMemberTotal(int mode, int cid)
        {
            string strSql = "select count(*) from member where 1=1";
            switch (mode)
            {
                case 0://查询可用会员数据
                    strSql += " and mstatus=0";
                    break;
                case 1://查询不可用会员数据
                    strSql += " and mstatus=1";
                    break;
                case 2://查询所有会员
                    break;
            }
            if (cid > 0)
            {
                strSql += " and mcid=" + cid;
            }
            DataTable objDataTable = new DataTable();
            new SQLHelper().ExecuteSql(strSql, out objDataTable);
            return int.Parse(objDataTable.Rows[0][0].ToString());
        }

        /// <summary>新增会员信息。</summary>
        /// <returns></returns>
        public int InsertMember()
        {
            string strSql = "insert member(mid,mname,mstatus,mcid,mpass,mremark,msex,mmonth,mday,mphone,maddress,mother,mjoin,midcard,mbalance,ifyxq,yxq,shengao,tizhong,xiongwei,yaowei,tunwei,image,biwei,tuiwei,mpoint,age,累计积分) values(@mid,@mname,@mstatus,@mcid,@mpass,@mremark,@msex,@mmonth,@mday,@mphone,@maddress,@mother,@mjoin,@midcard,@mbalance,@ifyxq,@yxq,@shengao,@tizhong,@xiongwei,@yaowei,@tunwei,@image,@biwei,@tuiwei,0,@age,'0.00')";
            SqlParameter[] cmdParameter =
                {
                    new SqlParameter("@mid", this.ID),
                    new SqlParameter("@mname", this.Name),
                    new SqlParameter("@mstatus", this.Status),
                    new SqlParameter("@mcid", this.CardID),
                    new SqlParameter("@mpass", this.Password),
                    new SqlParameter("@mremark", this.Remark),
                    new SqlParameter("@msex", this.Sex),
                    new SqlParameter("@mmonth", this.Month),
                    new SqlParameter("@mday", this.Day),
                    new SqlParameter("@mphone", this.Phone),
                    new SqlParameter("@maddress", this.Address),
                    new SqlParameter("@mother", this.Other),
                    new SqlParameter("@mjoin", this.JoinDate),
                    new SqlParameter("@midcard", this.IDCard),
                    new SqlParameter("@mbalance",this.Balance),
                    new SqlParameter("@ifyxq",this.Ifyxq),
                    new SqlParameter("@yxq",this.Yxq),
                    new SqlParameter("@shengao",this.Shengao),
                    new SqlParameter("@tizhong",this.Tizhong),
                    new SqlParameter("@xiongwei",this.Xiongwei),
                    new SqlParameter("@yaowei",this.Yaowei),
                    new SqlParameter("@tunwei",this.Tunwei),
                    new SqlParameter("@image",this.Image),
                    new SqlParameter("@biwei",this.Biwei),
                    new SqlParameter("@tuiwei",this.Tuiwei),
                    new SqlParameter("@age",this.Age)
                };
            return new SQLHelper().ExecuteSql(strSql, cmdParameter);
        }

        /// <summary>编辑会员信息。</summary>
        /// <returns></returns>
        public int UpdateMember()
        {
            string strSql = "update member set mname=@mname,mstatus=@mstatus,mcid=@mcid,mpass=@mpass,mremark=@mremark,msex=@msex,mmonth=@mmonth,mday=@mday,mphone=@mphone,maddress=@maddress,mother=@mother,midcard=@midcard,ifyxq=@ifyxq,yxq=@yxq,shengao=@shengao,tizhong=@tizhong,xiongwei=@xiongwei,yaowei=@yaowei,tunwei=@tunwei,image=@image,biwei=@biwei,tuiwei=@tuiwei,age=@age,会员级别=@会员级别 where mid=@mid";
            SqlParameter[] cmdParameter =
                {
                    new SqlParameter("@mid", this.ID),
                    new SqlParameter("@mname", this.Name),
                    new SqlParameter("@mstatus", this.Status),
                    new SqlParameter("@mcid", this.CardID),
                    new SqlParameter("@mpass", this.Password),
                    new SqlParameter("@mremark", this.Remark),
                    new SqlParameter("@msex", this.Sex),
                    new SqlParameter("@mmonth", this.Month),
                    new SqlParameter("@mday", this.Day),
                    new SqlParameter("@mphone", this.Phone),
                    new SqlParameter("@maddress", this.Address),
                    new SqlParameter("@mother", this.Other),
                    new SqlParameter("@mjoin", this.JoinDate),
                    new SqlParameter("@midcard", this.IDCard),
                    new SqlParameter("@ifyxq",this.ifyxq),
                    new SqlParameter("@yxq",this.yxq),
                    new SqlParameter("@shengao",this.shengao),
                    new SqlParameter("@tizhong",this.tizhong),
                    new SqlParameter("@xiongwei",this.xiongwei),
                    new SqlParameter("@yaowei",this.yaowei),
                    new SqlParameter("@tunwei",this.tunwei),
                    new SqlParameter("@image",this.Image),
                    new SqlParameter("@biwei",this.Biwei),
                    new SqlParameter("@tuiwei",this.Tuiwei),
                    new SqlParameter("@age",this.Age),
                    new SqlParameter("@会员级别",this.会员级别)
                };
            return new SQLHelper().ExecuteSql(strSql, cmdParameter);
        }

        /// <summary>更新会员状态(退卡)。</summary>
        /// <returns></returns>
        public int UpdateStatus()
        {
            string strSql = "update member set mstatus=1,mremark=@Remark where mid=@ID";
            SqlParameter[] cmdParameter = { new SqlParameter("@Remark", this.Remark), new SqlParameter("@ID", this.ID) };
            return new SQLHelper().ExecuteSql(strSql, cmdParameter);
        }

        /// <summary>会员换卡</summary>
        /// <param name="oldmember">旧会员卡信息</param>
        /// <param name="newid">新卡号</param>
        /// <returns></returns>
        public bool UpdateExchange(Member oldmember, string newid)
        {
            //string cardid = this.dgvMember.CurrentRow.Cells[0].Value.ToString();
            //更换卡号
           
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql = string.Format("UPDATE [member] SET [mid] = '{0}' WHERE mid='{1}'", newid,Member.oldcard);
            SqlCommand comm = new SqlCommand(sql, conn);
            comm.ExecuteNonQuery();
            //修改csmx
            SqlConnection conn2 = new SqlConnection(constr);
            conn2.Open();
            string sql2 = string.Format( "UPDATE [csmx] SET [cardID] = '{0}'  WHERE cardID='{1}'",newid, Member.oldcard);
            SqlCommand comm2 = new SqlCommand(sql2,conn2);
            comm2.ExecuteNonQuery();
            SqlConnection conn3 = new SqlConnection(constr);
            conn3.Open();
            string sql3 = string.Format("UPDATE [jcxf] SET [cardid] = '{0}' WHERE cardid='{1}'",newid, Member.oldcard);
            SqlCommand comm3 = new SqlCommand(sql3,conn3);
            comm3.ExecuteNonQuery();
            SqlConnection conn4 = new SqlConnection(constr);
            conn4.Open();
            string sql4 = string.Format("UPDATE [计次充值]SET  [卡号] = '{0}'  WHERE 卡号='{1}'",newid, Member.oldcard);
            SqlCommand comm4 = new SqlCommand(sql4,conn4);
            comm4.ExecuteNonQuery();
            SqlConnection conn5 = new SqlConnection(constr);
            conn5.Open();
            string sql5 = string.Format("UPDATE [ycxm] SET [cardID] = '{0}' WHERE cardID='{1}'",newid, Member.oldcard);
            SqlCommand comm5 = new SqlCommand(sql5,conn5);
            comm5.ExecuteNonQuery();
            SqlConnection conn6 = new SqlConnection(constr);
            conn6.Open();
            string sql6 =string.Format( "UPDATE [项目充值明细]  SET [cardid] = '{0}'  WHERE cardid='{1}'",newid, Member.oldcard);
            SqlCommand comm6 = new SqlCommand(sql6,conn6);
            comm6.ExecuteNonQuery();
            SqlConnection conn7 = new SqlConnection(constr);
            conn7.Open();
            string sql7 =string.Format( "UPDATE [会员续期] SET [卡号] = '{0}'  WHERE 卡号='{1}'",newid, Member.oldcard);
            SqlCommand comm7 = new SqlCommand(sql7,conn7);
            comm7.ExecuteNonQuery();
            SqlConnection conn8 = new SqlConnection(constr);
            conn8.Open();
            string sql8 =string.Format( "UPDATE [销售表] SET  [卡号] = '{0}' WHERE 卡号='{1}'",newid, Member.oldcard);
            SqlCommand comm8 = new SqlCommand(sql8,conn8);
            comm8.ExecuteNonQuery();
            SqlConnection conn9 = new SqlConnection(constr);
            conn9.Open();
            string sql9 = string.Format("UPDATE [销售明细] SET [会员卡号] ='{0}' WHERE 会员卡号='{1}'",newid, Member.oldcard);
            SqlCommand comm9 = new SqlCommand(sql9,conn9);
            comm9.ExecuteNonQuery();
            SqlConnection conn10 = new SqlConnection(constr);
            conn10.Open();
            string sql10 =string.Format( "UPDATE [制卡] SET [fl] = 1 WHERE card='{0}'", Member.oldcard);
            SqlCommand comm10 = new SqlCommand(sql10,conn10);
            comm10.ExecuteNonQuery();


            /* bool flag = new SQLHelper().ExecuteTransaction(strSql, lstParameter, 4);
             if (flag)
             {
                 this.UpdateBalance(oldmember.ID);
                 this.UpdateBalance(newid);
             }
             return flag;
             */
            return true;
        }

        /// <summary>更新会员余额。</summary>
        /// <param name="memberid">会员卡号</param>
        public void UpdateBalance(string memberid)
        {
            decimal dSumDeposit = Deposit.GetTotalMoneyForMember(memberid);
            decimal dSumPays = Pays.GetTotalPayForMember(memberid, 1, 0, 0, 0);
            decimal dResult = dSumDeposit - dSumPays;
            string strSql = "update member set mbalance=" + dResult + " where mid='" + memberid + "'";
            new SQLHelper().ExecuteSql(strSql);
        }

        public int UpdateLastTime(string memberid, DateTime lasttime)
        {
            string strSql = "update member set mlastime=@mlastime where mid=@mid";
            SqlParameter[] cmdParameter = { new SqlParameter("@mlastime", lasttime), new SqlParameter("@mid", memberid) };
            return new SQLHelper().ExecuteSql(strSql, cmdParameter);
        }

        /// <summary>更新会员积分</summary>
        /// <param name="memberid">会员卡号</param>
        private void UpdatePoint(string memberid)
        {
            
        }
        public List<Member> Selectcardfllist(string membertext, bool enabled, int sex)
        {
            //优先显示生日会员
            //string strSql1 = "select *,(select sum(dmoney) from deposit where dmid=member.mid) as sumdep,(select sum(pmoney) from pays where pmid=member.mid and ptype=1) as sumpay from member where (datepart(month,getdate())<=mmonth and datepart(day,getdate())<=mday)";
            string strSql1 = "select * from member where (datepart(month,getdate())<=mmonth and datepart(day,getdate())<=mday) and mcid=" + sex;
            string strSql2 = "select * from member where 1=1 and mcid=" + sex;
            if (membertext != "")
            {
                strSql1 += " and (mid like '%" + membertext + "%' or mname like '%" + membertext + "%' or mphone like '%" + membertext + "%')";
                strSql2 += " and (mid like '%" + membertext + "%' or mname like '%" + membertext + "%' or mphone like '%" + membertext + "%')";
            }
            if (enabled)
            {
                strSql1 += " and mstatus=1";
                strSql2 += " and mstatus=1";
            }
            else
            {
                strSql1 += " and mstatus=0";
                strSql2 += " and mstatus=0";
            }
            strSql1 += " order by mmonth,mday";
            strSql2 += " order by mmonth,mday";
            DataTable objTable1 = StaticValue.SelectTable(strSql1);
            DataTable objTable2 = StaticValue.SelectTable(strSql2);
            //合并表
            objTable1.Merge(objTable2);
            DataTable objTable = StaticValue.GetDistinctTable(objTable1, "mid");
            List<Member> lstMember = new List<Member>();
            foreach (DataRow objRow in objTable.Rows)
            {
                lstMember.Add(this.GetMemberForRow(objRow));
            }
            return lstMember;
        }
        public List<Member> Selectsexlist(string membertext, bool enabled,int sex)
        {
            //优先显示生日会员
            //string strSql1 = "select *,(select sum(dmoney) from deposit where dmid=member.mid) as sumdep,(select sum(pmoney) from pays where pmid=member.mid and ptype=1) as sumpay from member where (datepart(month,getdate())<=mmonth and datepart(day,getdate())<=mday)";
            string strSql1 = "select * from member where (datepart(month,getdate())<=mmonth and datepart(day,getdate())<=mday) and msex="+sex;
            string strSql2 = "select * from member where 1=1 and msex="+sex;
            if (membertext != "")
            {
                strSql1 += " and (mid like '%" + membertext + "%' or mname like '%" + membertext + "%' or mphone like '%" + membertext + "%')";
                strSql2 += " and (mid like '%" + membertext + "%' or mname like '%" + membertext + "%' or mphone like '%" + membertext + "%')";
            }
            if (enabled)
            {
                strSql1 += " and mstatus=1";
                strSql2 += " and mstatus=1";
            }
            else
            {
                strSql1 += " and mstatus=0";
                strSql2 += " and mstatus=0";
            }
            strSql1 += " order by mmonth,mday";
            strSql2 += " order by mmonth,mday";
            DataTable objTable1 = StaticValue.SelectTable(strSql1);
            DataTable objTable2 = StaticValue.SelectTable(strSql2);
            //合并表
            objTable1.Merge(objTable2);
            DataTable objTable = StaticValue.GetDistinctTable(objTable1, "mid");
            List<Member> lstMember = new List<Member>();
            foreach (DataRow objRow in objTable.Rows)
            {
                lstMember.Add(this.GetMemberForRow(objRow));
            }
            return lstMember;
        }   

        #endregion
    }
}
